package com.investmenttechnologyservices.model;

import java.util.Map;

import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Key;
/**
 * This class can be used to describe a benchmark, a fund or an index. 
 * It consists of a map of instruments with either a weight (true) or the number of shares (false).
 * 
 *  When retrieving from the list, it should be done recursively. If a list includes another instrument
 *  which itself is of this class
 *  
 * @author david.goodman
 *
 */
public class WeightedInstrumentList extends Instrument{
	
	public WeightedInstrumentList(Entity entity) {
		super(entity);
	}
	
	public WeightedInstrumentList(String key, Key firmKey, String name, Key issuerKey, 
			Map<Key, Double> benchmarkMembers) {
	    super(key, firmKey, name, issuerKey, InstrumentType.EQUITY);
		setBenchmarkMembers(benchmarkMembers);
	}

	public Boolean getWeight() {return (Boolean)getProperty("weight");}
	public void setWeight(Boolean weight) {setProperty("weight",weight);}
	
	@SuppressWarnings("unchecked")
	public Map<Key,Double> getBenchmarkMembers(){return (Map<Key,Double>)getProperty("benchmarkMembers");}
	public void setBenchmarkMembers(Map<Key, Double> benchmarkMembers) {
		setProperty("benchmarkMembers",benchmarkMembers);
	}
	
}
